home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 2.7 KB | 106 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPriStr.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPRISTR_H
- #define FWPRISTR_H
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #include <stddef.h>
-
- #ifdef FW_BUILD_WIN
- #include <ctype.h>
- // Include for toupper, tolower, isspace
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- size_t FW_FUNC_ATTR FW_PrimitiveStringLength(const char * p);
- // Returns the length of string p.
-
- int FW_FUNC_ATTR FW_PrimitiveStringEqual(const char *p1, const char *p2);
- // Compares string p1 to p2. Returns 1 if equal and 0 if false.
-
- void FW_FUNC_ATTR FW_PrimitiveStringCopy(const char *source, char *destination);
- // Copies string source to string destination.
- // Assumes that destination is large enough!
-
- void FW_FUNC_ATTR FW_PrimitiveStringCatenate(const char *source, char *destination);
- // Appends string source onto string destination.
- // Assumes that destination is large enough!
-
- FW_FUNC_ATTR char * FW_PrimitiveStringFindCharacter(const char *source, char c);
- // Return pointer to first occurrence of c in source or NULL if not present.
-
- char FW_FUNC_ATTR FW_PrimitiveCharacterToUpper(char c);
- // Return character c converted to upper case.
-
- char FW_FUNC_ATTR FW_PrimitiveCharacterToLower(char c);
- // Return character c converted to lower case.
-
- char FW_FUNC_ATTR FW_PrimitiveCharacterIsSpace(char c);
- // Returns non-zero if character is space, tab, carriage return, or newline.
-
- //========================================================================================
- // FWPriStr.h inlines
- //========================================================================================
-
- inline char FW_PrimitiveCharacterToUpper(char c)
- {
- #ifdef FW_BUILD_MAC
- if (c >= 'a' && c <= 'z')
- return (c - 'a' + 'A');
- else
- return (c);
- #endif
-
- // Use the standard library version to take advantage of locale information
- #ifdef FW_BUILD_WIN
- return toupper(c);
- #endif
- }
-
-
- inline char FW_PrimitiveCharacterToLower(char c)
- {
- #ifdef FW_BUILD_MAC
- if (c >= 'A' && c <= 'Z')
- return (c + 'a' - 'A');
- else
- return (c);
- #endif
-
- // Use the standard library version to take advantage of locale information
- #ifdef FW_BUILD_WIN
- return tolower(c);
- #endif
- }
-
- inline char FW_PrimitiveCharacterIsSpace(char c)
- {
- #ifdef FW_BUILD_MAC
- return ((c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f') ? c : 0);
- #endif
-
- // Use the standard library version to take advantage of locale information
- #ifdef FW_BUILD_WIN
- return isspace(c);
- #endif
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-